<template>
  <div class="">
    <input type="text" v-model="title" @keydown.enter="add" />
  </div>
</template>

<script>
export default {
  data() {
    return {
      title: "",
    };
  },
  created() {},
  methods: {
    add() {
      if (this.title == "") {
        alert("不能为空");
        return false;
      }
      this.$store.commit("add", this.title);
      this.title = "";
      //假设commit要传多个参数 就传成一个对象{}
    },
  },
  components: {},
};
</script>

<style lang="scss"></style>
